import promise from 'redux-promise'
import { logger, checker } from '../middlewares'
import { applyMiddleware, createStore, combineReducers } from 'redux'
import reducers from '../reducers'
import { browserHistory } from 'react-router'

export default () => {
	const createStoreWithMiddleware = applyMiddleware(
		promise,
    //logger,
		checker
	)(createStore)

	const store = createStoreWithMiddleware(reducers)

	if (module.hot) {
		module.hot.accept('../reducers', () => {
			const nextReducer = require('../reducers')
			store.replaceReducer(nextReducer)
		})
	}

	return store
}
